/**
 * 
 */
package com.sx.feesunit.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sx.core.BaseDao;
import com.sx.feesunit.dao.IUserUnitDao;
import com.sx.feesunit.entity.UserUnitEntity;
import com.sx.feesunit.exception.SXException;


/**
 * @author Administrator
 *
 */
public class UserUnitDao extends BaseDao implements IUserUnitDao {
	private Log log = LogFactory.getLog(this.getClass());
	/**
	 *查询用户是否欠费数据信息 
	 **/
	public List<UserUnitEntity> findUserUnitInfoIsOwed(UserUnitEntity userunit) throws Exception {
		List<UserUnitEntity> list = new ArrayList<UserUnitEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("UserUnit.findUserUnitInfoIsOwed",userunit);
		} catch (Exception e) {
			log.error("查询用户是否欠费数据信息",e);
		}
		return list;
	}
	public Integer addUserUnitInfo(UserUnitEntity userunit) throws Exception {
		try {
			return super.addInfo(userunit, "UserUnit.addUnitEntityInfo");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("新增用户失败",e);
			return new Integer(0);
		}
	}


	public boolean deleteUserUnitInfo(UserUnitEntity userunit) throws Exception {
		try {
			return super.delInfo(userunit, "UserUnit.deleteUserUnitInfo");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("删除用户失败",e);
			return false;
		}
	}

	
	public List<UserUnitEntity> findUserUnitInfo(UserUnitEntity userunit) throws Exception {
		List<UserUnitEntity> list = new ArrayList<UserUnitEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("UserUnit.findUserUnitInfo",userunit);
		} catch (Exception e) {
			log.error("查询用户失败",e);
		}
		return list;
	}
 
	
	public List<UserUnitEntity> findUserUnitInfoByAndCondiction(UserUnitEntity userunit)
			throws Exception {
		List<UserUnitEntity> list = new ArrayList<UserUnitEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("UserUnit.findUserUnitByAndCondiction",userunit);
		} catch (Exception e) {
			log.error("分页查询用户And连接失败",e);
		}
		return list;
	}

	
	public List<UserUnitEntity> findUserUnitInfoByOrCondiction(UserUnitEntity userunit)
			throws Exception {
		List<UserUnitEntity> list = new ArrayList<UserUnitEntity>();
		try {
			list = super.getSqlMapClientTemplate().queryForList("UserUnit.findUserUnitInfoByOrCondiction",userunit);
		} catch (Exception e) {
			log.error("分页查询用户Or连接失败",e);
		}
		return list;
	}

	public boolean updateUserUnitInfo(UserUnitEntity userunit) throws Exception {
		boolean flag = false;
		try{
			flag = super.updateInfo(userunit,"UserUnit.updateUserUnitInfo");
		}catch(Exception ex){
			log.error("修改用户失败",ex);
		}
		return flag;
	}

}
